Calculated Columns

The Calculated Columns node enables users to manipulate columns during the data flow using a PQL script. Once the node has been connected to the relevant table, provide a PQL script in order to create or manipulate column values, or perform calculations on existing column values, and add these manipulations as an additional column.

While the other column operation functions offer shortcuts to standard column operations, the calculated column is more advanced. It produces a new column of values using free-form functions based on a user-defined PQL expression.

You can provide a SQL expression by writing or pasting it directly into the quick script editor, or you can open the PQL formula editor. The PQL editor exposes the data model's meta-structures, and features drag and drop functionality and intellisense, so that you can easily pick and choose the required functions and metadata.

  • Click here to learn more about the PQL editor.
  • Click here to review the 'Common' PQL functions.

Quick Script Editor

Write a PQL expression in the quick script editor (purple arrow below):

  • Use square brackets to select a column
  • PQL scripts are case-sensitive - make sure that column headings are written in the correct case

Select the Replace Original Column checkbox (yellow arrow) to replace the existing column with the new calculated column. If this checkbox is clear, the new column will be added to the table alongside the original.

Under Calculated Column Name (green highlight) provide a name for the new column, and under Calculate Column Type select the relevant column type.

PQL Editor

The PQL Editor is a script-writing interface with drag and drop functionality and intellisense. The editor exposes meta structure of the data model, as well as the menu of PQL functions. Using drag and drop functionality you can construct your PQL expression by selecting the required functions and metadata.

Open the PQL Editor by clicking the Advanced Script button (blue arrow above) in the Calculated Column panel.

  • Click here to learn more about the PQL editor.

Adding a Calculated Column

Step 1: Add your node

Drag the Calculated Column node onto the canvas and connect it to the relevant table.

Step 2: Write your PQL Script

You can write your script in one of the following locations:

  1. In the Script window (purple arrow above), you can write your PQL expression directly.
  2. You can also click PQL Editor (blue arrow) to open the PQL editor, where you can select your required functions, columns, variables, and elements for your PQL expression.
  • Click here for more information about PQL

Type the following script:

IF([Margin]>0.3, IF(floor([OverHead])> 100, "High Margin with Overhead", "High Margin"), "Low Margin")

Select the following options:

  • Replace Original Column: Clear this checkbox (yellow arrow above), to add the new calculated column to the table alongside the original column.
  • Calculate Column Name: Give your new column the name "Margin Description" (green highlight).

Step 3: Preview your Result

Click the Eye icon at the top of the Preview panel or Properties panel to preview the result. As shown in the initial example (orange highlight above), the Margin Description column is shown in the preview.

  • Click here for more information about previewing

Example Calculated Columns

Related information

Common Properties

There are a number of fields that are present in the Properties panel when you have any of the preceding nodes selected on the canvas. These fields include Result Properties, Column Selection, Set Variable Values, and Metadata.

  • Click here for more details about the Common Properties